<div class="layui-form" lay-filter="layuiadmin-form-role" id="form">
	<div class="form-cont">
		<div class="layui-form-item verify">
		  <label class="layui-form-label">活动类型</label>
		  <div class="layui-input-block">
			  <div class="layui-unselect layui-form-select">
			  	<div class="layui-select-title"><input type="text" name='activity' :data='detail.activity' placeholder="请选择活动类型" class="layui-input layui-unselect" readonly><i
			  		 class="layui-edge"></i></div>
			  	<dl class="layui-anim layui-anim-upbit type_select">
			  		<dd class="layui-select-tips layui-this" data="">活动类型</dd>
			  		<dd :data='index+1' v-for="(x,index) in activity">{{x}}</dd>
			  	</dl>
			  </div>
			  <span class="hint">活动范围必填</span>
			</div>
		</div>
		
		<div class="layui-form-item verify">
		  <label class="layui-form-label">活动范围</label>
		  <div class="layui-input-block">
			  <div class="layui-unselect layui-form-select">
			  	<div class="layui-select-title"><input type="text" name='type' :data='detail.type' placeholder="请选择活动范围" class="layui-input layui-unselect" readonly><i
			  		 class="layui-edge"></i></div>
			  	<dl class="layui-anim layui-anim-upbit type_select">
			  		<dd class="layui-select-tips layui-this" data="">活动范围</dd>
			  		<dd :data='index+1' v-for="(x,index) in types">{{x}}</dd>
			  	</dl>
			  </div>
			  <span class="hint">活动范围必填</span>
			</div>
		</div>
		
		<div class="layui-form-item verify">
		  <label class="layui-form-label">活动名称</label>
		  <div class="layui-input-block">
			  <!-- <div class="layui-unselect layui-form-select">
			  	<div class="layui-select-title"><input type="text" name='activity_name' :data='detail.activity_name' placeholder="请选择范围" class="layui-input layui-unselect" readonly><i
			  		 class="layui-edge"></i></div>
			  	<dl class="layui-anim layui-anim-upbit">
			  		<dd class="layui-select-tips layui-this">活动范围</dd>
			  		<dd data='0'>本年</dd>
					<dd data='1'>本季</dd>
					<dd data='2'>本月</dd>
					<dd data='2'>本周</dd>
					<dd data='2'>本日</dd>
			  	</dl>
			  </div> -->
			  <input type="text" autocomplete="off" verify='require' v-model="detail.activity_name" placeholder="请输入活动名称" class="layui-input">
			  <span class="hint">活动名称必填</span>
			</div>
		</div>
		<!-- <div class="layui-form-item verify">
		  <label class="layui-form-label">活动范围</label>
		  <div class="layui-input-block">
			  <div class="layui-unselect layui-form-select">
			  	<div class="layui-select-title"><input type="text" name='type' :data='detail.type' placeholder="请选择活动范围" class="layui-input layui-unselect" readonly><i
			  		 class="layui-edge"></i></div>
			  	<dl class="layui-anim layui-anim-upbit">
			  		<dd class="layui-select-tips layui-this">活动范围</dd>
			  		<dd :data='index+1' v-for="(x,index) in types">{{x}}</dd>
			  	</dl>
			  </div>
			  <span class="hint">活动范围必填</span>
			</div>
		</div> -->
		<div class="layui-form-item verify">
		  <label class="layui-form-label">满足时间</label>
		  <div class="layui-input-block">
		      <input type="number" style="display: inline-block; margin-right: 10px; width: 60%;" autocomplete="off" verify='require' v-model="detail.grand_total" placeholder="请输入满足时间" class="layui-input">{{unit[unit-1]}}
				<span class="hint">满足时间必填</span>
		  </div>
		</div>

		<div class="layui-form-item verify">
		  <label class="layui-form-label" style="padding: 9px 12px;width: 85px;">时间换算单位</label>
		  <div class="layui-input-block">
		      <div class="layui-unselect layui-form-select">
		      	<div class="layui-select-title"><input type="text" name='unit' :data='detail.unit' placeholder="请选择时间换算单位" class="layui-input layui-unselect" readonly><i
		      		 class="layui-edge"></i></div>
		      	<dl class="layui-anim layui-anim-upbit">
		      		<dd class="layui-select-tips layui-this">时间换算单位</dd>
		      		<dd :data='index+1' v-for="(x,index) in unit">{{x}}</dd>
		      	</dl>
		      </div>
				<span class="hint">时间换算单位必选</span>
		  </div>
		</div>

		<div class="layui-form-item verify">
		  <label class="layui-form-label">价格</label>
		  <div class="layui-input-block">
		      <input type="number" style="display: inline-block; margin-right: 10px; width: 60%;" autocomplete="off" verify='require' v-model="detail.price" placeholder="请输入价格" class="layui-input">（元）
				<span class="hint">价格必填</span>
		  </div>
		</div>
		
		<div class="layui-form-item verify">
		  <label class="layui-form-label">活动说明</label>
		  <div class="layui-input-block">
		      <textarea type="text" class="layui-textarea" v-model="detail.detail" verify='require'></textarea>
			  <span class="hint">活动说明必填</span>
		  </div>
		</div>
		<div class="layui-form-item">
		  <label class="layui-form-label">状态</label>
		  <div class="layui-input-block">
		      <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'启用':'停用'}}</em><i></i></div>
		  </div>
		</div>
	</div>
  
  <div class="form-btn" v-if="type!=3">
      <input type="button" value="保存" class="layui-btn" @click="submit">
  </div>
</div>

<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var form=new Vue({
	  		el:'#form',
	  		data:{
	  			detail:{
					status:1,
					activity:'',
					unit:'',
					type:''
				},
				activity:['免费活动','包机活动'],
				types:['年','季','月','周','日'],
				unit:['小时','天'],
				old_detail:{},
				type:layui.admin.objData.type
	  		},
	  		mounted() {
				//初始化
	  			if(this.type!=1) this.detail=layui.admin.objData.detail,this.old_detail=JSON.stringify(layui.admin.objData.detail);
				/* $('input[name="type"]').val(this.types[this.detail.type-1]);
				$('input[name="unit"]').val(this.unit[this.detail.unit-1]); */
				console.log(this.detail);
	  		},
	  		methods:{
				radioF(){//radio选择
					this.detail.status==1?this.detail.status=2:this.detail.status=1;
				},
				submit(){
					if(layui.admin.form('#form')){
						//this.detail.type=parseInt($(".type_select .layui-this").attr('data'));
	  					this.detail.type=parseInt($('input[name="type"]').attr('data'));
	  					this.detail.unit=parseInt($('input[name="unit"]').attr('data'));
	  					this.detail.activity=parseInt($('input[name="activity"]').attr('data'));
						
						//console.log(this.detail);

						layui.admin.formapi('activity/add',this.detail,'list-select-table1');

					}
				}
	  		}
	  	})
	});
</script>
